package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wechat.domain.Evaluate;
import com.ruoyi.wechat.service.IEvaluateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(value = "微信小程序API-营地评价管理",tags={"微信小程序API-营地评价管理"})
@RestController
@RequestMapping("/wechat/evaluate")
public class WxEvaluateController extends BaseController {
    @Autowired
    private IEvaluateService evaluateService;
    /**
     * 新增-营地评价
     * RequestBody-jsOn格式
     */
    @ApiOperation(value="添加评论")
    @Log(title = "微信接口-营地评价",businessType = BusinessType.INSERT)
    @PostMapping("wxadd")
    public AjaxResult add(@RequestBody Evaluate evaluate)
    {
       return  toAjax(evaluateService.insertEvaluate(evaluate));
    }
    /**
     * 查询-营地评价
     * 无--params格式
     */
    @ApiOperation(value="根据营地ID获取该营地下的所有评论")
    @ApiImplicitParams({
            @ApiImplicitParam(name="campId",value = "营地Id",required = true,dataType = "String",paramType = "query"),
    })

    @GetMapping("/wxlist")
    public AjaxResult list(Evaluate evaluate)
    {
        List<Evaluate> list = evaluateService.selectEvaluateList(evaluate);


        return  success(list);
    }

    @ApiOperation(value="根据评论ID获取该评论的所有信息")
    @GetMapping("/wxgetInfo/{evaluateId}")
    public AjaxResult getInfo(@PathVariable("evaluateId") String evaluateId )
    {



        return  success(evaluateService.selectEvaluateByEvaluateId(evaluateId));
    }

    /**
     * path---1
     * @param evaluateId
     * @return
     */
    @ApiOperation(value="根据评论ID删除数据")
    @Log(title = "微信接口-营地评价",businessType = BusinessType.INSERT)
    @DeleteMapping("/delete/{evaluateId}")
    public AjaxResult remove(@PathVariable String evaluateId)
    {
        return  toAjax(evaluateService.deleteEvaluateByEvaluateId(evaluateId));
    }




}
